Skip to content

GDPR consent authorization fix; wire dead analytics/governance modules; drop placeholder submodules - #1047

Merged
nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
limxiy:feature/gdpr-consent-auth-and-dead-code-cleanup
Aug 25, 2026
Merged

GDPR consent authorization fix; wire dead analytics/governance modules; drop placeholder submodules#1047
nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
limxiy:feature/gdpr-consent-auth-and-dead-code-cleanup

Conversation

@limxiy

@limxiy limxiy commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

One commit, four assigned issues: a security fix in the GDPR consent registry, plus three dead-code/placeholder cleanups that make previously invisible code compile and run its tests.

gdpr — consent-grant authorization (#984) [security]

grant_consent accepted any data_subject with zero caller checks (the function body never referenced caller), while its sibling withdraw_consent enforced data_subject == caller || caller == admin. An attacker could fabricate a Granted ConsentRecord for any victim, which then flowed into check_consent (and the data-access path) as if the victim had consented — defeating the registry's entire purpose, since consent is the legal basis for processing.

Fix: mirror withdraw_consent's rule exactly. The policy (subject grants own consent; admin may record on behalf) is documented on the message.

Tests: third-party grant rejected (Error::NotAuthorized) leaving no fabricated record and check_consent false; subject self-grant succeeds; admin grant-on-behalf succeeds.

analytics — compile the dead staking_dashboard module (#983)

staking_dashboard.rs was never declared anywhere, so none of it was compiled and all 17 of its unit tests silently never ran (the analytics crate had no other tests).

Fix: pub mod staking_dashboard;. Also fixed its never-compiled test helper: ink::env::test::run_test returns Result<()> and cannot smuggle a constructed value out; the helper now constructs directly inside the #[ink::test] environment. All tests now execute under cargo test -p propchain-analytics.

governance — wire treasury/delegation/snapshot modules (#982)

treasury.rs, delegation.rs, and snapshot_tests.rs were orphan files: lib.rs included only errors/types/tests, so governance shipped no treasury or delegation feature at all despite full implementations sitting inert in the tree.

Fix: declared as root-level modules (pub mod treasury;, pub mod delegation;, test-only mod snapshot_tests;) with extern crate alloc for no_std builds. They now compile and their 12 unit tests run under cargo test -p governance. Wiring them into the contract's storage/message surface is a feature decision beyond this fix and is documented as such in lib.rs.

property-management — remove placeholder submodules (#973)

submodules::property_registry::is_registered(id) returned id > 0 (can never detect an unregistered property) and submodules::property_maintenance::schedule_inspection(id) claimed success for any positive id without recording anything. No callers existed; the names promised semantics the crate doesn't have.

Decision (documented): removed rather than implemented — real registry logic lives in lib.rs; making inspection scheduling real requires new storage/events/access-policy (a feature, not a fill-in).

Test results

  • cargo test -p propchain-gdpr: 14 passed (11 existing + 3 new)
  • cargo test -p propchain-analytics: 19 passed (17 staking_dashboard + 2 existing)
  • cargo test -p governance: 29 passed (18 existing + 5 treasury + 3 delegation + 4 snapshot... net +12 newly-compiled tests)
  • cargo test -p property-management: 8 passed (unchanged after stub removal)

Closes #984
Closes #983
Closes #982
Closes #973

…laceholder submodules

- gdpr (MettaChain#984): `grant_consent` accepted an arbitrary `data_subject`, letting
  any caller fabricate a `Granted` consent record in a victim's name (the
  record then satisfies `check_consent` and the data-access path). The
  function now mirrors `withdraw_consent`'s rule: the caller must be the
  data subject or the admin. Policy documented on the message. Tests cover
  third-party rejection (no fabricated record, check stays false),
  subject self-grant, and admin grant-on-behalf.
- analytics (MettaChain#983): wire the previously dead `staking_dashboard.rs` into
  the crate via `pub mod staking_dashboard;`. Fixed its never-compiled test
  helper (`run_test` cannot return a value; construction now relies on the
  `#[ink::test]` environment). Its 17 unit tests now run under
  `cargo test -p propchain-analytics`.
- governance (MettaChain#982): wire the three orphan files into the build:
  `pub mod treasury;`, `pub mod delegation;` and (test-only)
  `mod snapshot_tests;`, plus `extern crate alloc` for no_std builds.
  Their unit tests now run under `cargo test -p governance`; exposing them
  on the on-chain message surface remains a separate feature decision,
  documented in lib.rs.
- property-management (MettaChain#973): removed the placeholder `submodules` module
  whose `is_registered`/`schedule_inspection` stubs returned `id > 0` and
  promised semantics that do not exist (real registry logic lives in
  lib.rs). Removal chosen over implementation against real storage because
  inspection scheduling implies a new feature (storage + events + access
  policy) beyond this fix.

Closes MettaChain#984
Closes MettaChain#983
Closes MettaChain#982
Closes MettaChain#973
@drips-wave

drips-wave Bot commented Aug 24, 2026

Copy link
Copy Markdown

@limxiy Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@nanaf6203-bit
nanaf6203-bit merged commit 8a2a16d into MettaChain:main Aug 25, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment